/*************************************************************************
	> File Name: 001.Trie.cpp
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 三  2/24 15:03:24 2021
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//26个字母
#define BASE 26 

//完成字符串排序功能

typedef struct Node {
    int flag; //是否独立成词
    struct Node *next[BASE]; //26条边，a在第一个子孩子，b在第二个子孩子，.....
} Node;

Node *getNewNode() {
    Node *p = (Node *)malloc(sizeof(Node));
    p->flag = 0;
    memset(p->next, 0, sizeof(p->next)); //初始化next数组
    return p;
}

void insert(Node *p, const char *s) {
    for (int i = 0; s[i]; i++) {
        int ind = s[i] - 'a';
        if (p->next[ind] == NULL) p->next[ind] = getNewNode();
        p = p->next[ind];
    }
    p->flag = 1;
    return ;
}

void clear(Node *root) {
    if (root == NULL) return ;
    for (int i = 0; i < BASE; i++) {
        clear(root->next[i]);
    }
    free(root);
    return ;
}

//k：字典树的第几层
//s：读出来的字符串放置的buffer
void output(Node *root, int k, char *s) {
    s[k] = 0;
    if (root->flag) {
        printf("%s\n", s);
        return ;
    }

    for (int i = 0; i < BASE; i++) {
        if (root->next[i] == NULL) continue;
        s[k] = 'a' + i;
        output(root->next[i], k + 1, s);
    }
    return ;
}

int main() {
    int n;
    char str[100];
    scanf("%d", &n);
    Node *root = getNewNode();
    for (int i = 0; i < n; i++) {
        scanf("%s", str);
        insert(root, str);
    }
    output(root, 0, str);
    clear(root);
    return 0;
}


